package com.ruoyi.training.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.training.util.xuehua.SnowflakeIdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.training.mapper.A04ResMajorMapper;
import com.ruoyi.training.domain.A04ResMajor;
import com.ruoyi.training.service.IA04ResMajorService;

import javax.annotation.Resource;

/**
 * 课程库Service业务层处理
 * 
 * @author WorrilessGo
 * @date 2025-11-18
 */
@Service
public class A04ResMajorServiceImpl implements IA04ResMajorService 
{
    @Resource
    private A04ResMajorMapper a04ResMajorMapper;

    /**
     * 查询课程库
     * 
     * @param id 课程库主键
     * @return 课程库
     */
    @Override
    public A04ResMajor selectA04ResMajorById(String id)
    {
        return a04ResMajorMapper.selectA04ResMajorById(id);
    }

    /**
     * 查询课程库列表
     * 
     * @param a04ResMajor 课程库
     * @return 课程库
     */
    @Override
    public List<A04ResMajor> selectA04ResMajorList(A04ResMajor a04ResMajor)
    {
        return a04ResMajorMapper.selectA04ResMajorList(a04ResMajor);
    }

    /**
     * 新增课程库
     * 
     * @param a04ResMajor 课程库
     * @return 结果
     */
    @Override
    public int insertA04ResMajor(A04ResMajor a04ResMajor)
    {
        String id = String.valueOf(new SnowflakeIdUtils(5, 8).nextId());
        a04ResMajor.setCourseId(id);
        a04ResMajor.setCreateTime(DateUtils.getNowDate());
        return a04ResMajorMapper.insertA04ResMajor(a04ResMajor);
    }

    /**
     * 修改课程库
     * 
     * @param a04ResMajor 课程库
     * @return 结果
     */
    @Override
    public int updateA04ResMajor(A04ResMajor a04ResMajor)
    {
        a04ResMajor.setUpdateTime(DateUtils.getNowDate());
        return a04ResMajorMapper.updateA04ResMajor(a04ResMajor);
    }

    /**
     * 批量删除课程库
     * 
     * @param ids 需要删除的课程库主键
     * @return 结果
     */
    @Override
    public int deleteA04ResMajorByIds(String[] ids)
    {
        return a04ResMajorMapper.deleteA04ResMajorByIds(ids);
    }

    /**
     * 删除课程库信息
     * 
     * @param id 课程库主键
     * @return 结果
     */
    @Override
    public int deleteA04ResMajorById(String id)
    {
        return a04ResMajorMapper.deleteA04ResMajorById(id);
    }

    @Override
    public int batchInsertA04ResMajors(List<A04ResMajor> a04ResMajors) {
        a04ResMajors.forEach(s->{
            s.setCourseId(String.valueOf(new SnowflakeIdUtils(5, 8).nextId()));
        });
        return a04ResMajorMapper.batchInsertA04ResMajors(a04ResMajors);
    }
}
